package com.xi.demo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import java.time.Duration;

@RequestMapping("/fluxDemo")
@RestController
public class FluxDemoTest {
    public static void main(String[] args) throws InterruptedException {
        Flux<String> flux = Flux.just("Hello", "World");
        flux.map(x -> x.toUpperCase())
                .delayElements(Duration.ofSeconds(1))
                .subscribe(System.out::println);

        Thread.sleep(5000);
    }

    @RequestMapping("/sse")
    public Flux<String> sse() {

        return Flux
                .just("Hello", "World")
                .delayElements(Duration.ofSeconds(1));
    }
}
